﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Campus {
    class Biologist : Unit {
        static public List<Texture2D> idleAnim = new List<Texture2D>();
        static public List<Texture2D> walkRightAnim = new List<Texture2D>();
        static public List<Texture2D> walkLeftAnim = new List<Texture2D>();
        static public List<Texture2D> walkUpAnim = new List<Texture2D>();
        static public List<Texture2D> walkDownAnim = new List<Texture2D>();
        static public List<Texture2D> attackRightAnim = new List<Texture2D>();
        static public List<Texture2D> attackLeftAnim = new List<Texture2D>();
        static public List<Texture2D> dieAnim = new List<Texture2D>();

        private static Animation animalAnimation;
        static public void InitializeAnimalAnimation(ContentManager Content) 
        {
            List<Texture2D> animationList = new List<Texture2D>();
            animationList.Add(Content.Load<Texture2D>("Units/Biologist/rat_0"));
            animationList.Add(Content.Load<Texture2D>("Units/Biologist/rat_1"));
            animalAnimation = new Animation(animationList, 50, true);
        }
        private void CreateAbilites() {
            Abilities.Add("Move", new MoveAbility(this, Vector2.Zero));
            Abilities.Add("Attack", new RangedAttack(this, animalAnimation, Ability.TargetTypes.BaseEntityTarget,
                20, 25, 2000, 500));
            this.CanAttack = true;
        }
        public Biologist(Vector2 position, Player player, Level level)
            : base(CreateDictionary(), position, 50, player, level,
            new Dictionary<String, Ability>(), new Dictionary<String, AbilitySubMenu>()) {
            m_name = "Biologist";
            m_entitySelectedImage = idleAnim[0];
            Size = new Vector2(50, 50);
            CreateAbilites();

            this.LeftProjectileOffset = new Vector2(20.0f, 25.0f);
            this.RightProjectileOffset = new Vector2(50.0f, 5.0f);
        }

        static private Dictionary<Unit.UnitState, Animation> CreateDictionary() {
            Dictionary<Unit.UnitState, Animation> dict = new Dictionary<UnitState, Animation>();

            Random rgen = new Random();

            // Creates an animation based on the certain static list, then adds it to the
            // Dictionary under the appropriate state.
            dict.Add(UnitState.Idle, new Animation(idleAnim, rgen.Next(400, 600), true));

            dict.Add(UnitState.WalkRight, new Animation(walkRightAnim, 100, true));
            dict.Add(UnitState.WalkLeft, new Animation(walkLeftAnim, 100, true));
            dict.Add(UnitState.WalkDown, new Animation(walkDownAnim, 75, true));
            dict.Add(UnitState.WalkUp, new Animation(walkUpAnim, 75, true));
            dict.Add(UnitState.AttackRight, new Animation(attackRightAnim, 90, false));
            dict.Add(UnitState.AttackLeft, new Animation(attackLeftAnim, 90, false));
            dict.Add(UnitState.Die, new Animation(dieAnim, 100, false));

            return dict;
        }


        static public void InitializeAnimations(ContentManager Content) {
            // Loads all the idle animation frames
            idleAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistIDLE_0"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistIDLE_1"));
            idleAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistIDLE_2"));
            idleAnim.Add(idleAnim[1]);

            walkRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKRIGHT_0"));
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKRIGHT_1"));
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKRIGHT_2"));
            walkRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKRIGHT_3"));
            walkRightAnim.Add(walkRightAnim[2]);
            walkRightAnim.Add(walkRightAnim[1]);

            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKLEFT_0"));
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKLEFT_1"));
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKLEFT_2"));
            walkLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKLEFT_3"));
            walkLeftAnim.Add(walkLeftAnim[2]);
            walkLeftAnim.Add(walkLeftAnim[1]);

            walkUpAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKUP_0"));
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKUP_1"));
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKUP_2"));
            walkUpAnim.Add(walkUpAnim[1]);
            walkUpAnim.Add(walkUpAnim[0]);
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKUP_3"));
            walkUpAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKUP_4"));
            walkUpAnim.Add(walkUpAnim[5]);

            walkDownAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKDOWN_0"));
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKDOWN_1"));
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKDOWN_2"));
            walkDownAnim.Add(walkDownAnim[1]);
            walkDownAnim.Add(walkDownAnim[0]);
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKDOWN_3"));
            walkDownAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistWALKDOWN_4"));
            walkDownAnim.Add(walkDownAnim[5]);

            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_0"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_1"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_2"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_3"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_4"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_5"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_6"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_7"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_8"));
            attackRightAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKRIGHT_9"));
            attackRightAnim.Add(attackRightAnim[8]);

            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_0"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_1"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_2"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_3"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_4"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_5"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_6"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_7"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_8"));
            attackLeftAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistATTACKLEFT_9"));
            attackLeftAnim.Add(attackLeftAnim[8]);

            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_0"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_1"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_2"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_3"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_4"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_5"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_6"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_7"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_8"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_9"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_10"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_11"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_12"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_13"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_14"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_15"));
            dieAnim.Add(Content.Load<Texture2D>("Units/Biologist/biologistDEATH_16"));
        }
    }
}
